<?php

class Application_Model_People extends Zend_Db_Table_Abstract
{
protected $_name = 'family_people';

    public function getUser($id) {
        $id = (int) $id;
        $row = $this->fetchRow('person_id = ' . $id);
        if (!$row) {
            throw new Exception("Could not find row $id");
        }
        return $row->toArray();
    }

    public function addUser($death_reason, $gender, $mother_id, $father_id, $narrative, $updated, $creator_id, $created, $editor_id) {
        $data = array(
            'death_reason' => $death_reason, 
            'gender' => $gender, 
            'mother_id' => $mother_id, 
            'father_id' => $father_id, 
            'narrative' => $narrative, 
            'updated' => $updated, 
            'creator_id' => $creator_id, 
            'created' => $created, 
            'editor_id' => $editor_id
        );
        $this->insert($data);
    }

    public function updateUser($person_id, $death_reason, $gender, $mother_id, $father_id, $narrative, $updated, $creator_id, $created, $editor_id) {
        $data = array(
        'deathReason' => $death_reason, 
            'gender' => $gender, 
            'motherId' => $mother_id, 
            'fatherId' => $father_id, 
            'narrative' => $narrative, 
            'updated' => $updated, 
            'creatorId' => $creator_id, 
            'created' => $created, 
            'editorId' => $editor_id
        );
        $this->update($data, 'person_id = '. (int) $person_id);
    }



    public function deleteUser($id) {
        $this->delete('person_id =' . (int) $id);
    }
}

